var vm = new Vue({
    el: '#rrapp',
    data: {
        file:null,
    },
    methods: {
        importChangePrice: function () {
            if(vm.checkFile()){
                var formData = new FormData();
                var name = $("#upfile").val();
                formData.append("file",$("#upfile")[0].files[0]);
                formData.append("name",name);
                var ssssm = /\.[^\.]+/.exec(name);
                var sb1 = ssssm[0].substring(1,5);
                if(sb1!="xlsx" && sb1!= "xls"){
                    alert("请选择正确的excel文件");
                    return false;
                }
                $.ajax({
                    url: "/goods/goods/changePrice/upload",
                    type: "POST",
                    async: false,
                    data: formData,
                    processData: false,
                    contentType: false,
                    beforeSend:function () {
                        console.log("正在进行,请稍后");
                    },
                    success:function (r) {
                        if(r.code==0){
                            alert(r.msg);

                        }else{
                            alert(r.msg);
                            return false;

                        }
                    }
                });
            }
        },
        checkFile: function () {
            var file = $("#upfile")[0].files.length;
            if(file<=0){
                alert("请选择Excel文件导入");
                return false;
            }
            return true;
        },
    }
})

